package com.demo.config;

import org.redisson.Redisson;
import org.redisson.client.codec.Codec;
import org.redisson.codec.JsonJacksonCodec;
import org.redisson.config.Config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;


/**
 * @author gy
 * @date 2022/6/18
 */
@Configuration
public class RedissonConfig {
    @Bean
    public Redisson redisson(){
        // 此为单机模式
        Config config = new Config();
        config.useSingleServer().setAddress("redis://127.0.0.1:6379").setDatabase(5);
        Codec codec = new JsonJacksonCodec();
        config.setCodec(codec);
        return (Redisson) Redisson.create(config);
    }
}
